package particle;

import javax.media.opengl.GL;

import processing.core.PApplet;
import processing.core.PImage;
import processing.core.PVector;
import processing.opengl.PGraphicsOpenGL;

public class ParticleSystemDEMO extends PApplet{
	
	ParticleSystem ps;
	int mouseX_old;
	int mouseY_old;
	int width = 600;
	int height = 480;
	PImage newImg; 

	public void setup() {
		size(800, 800, OPENGL);
		colorMode(GRAY, 255, 255, 255, 100);
		ps = new ParticleSystem(1, new PVector(width/2,height/2,0));
		smooth();
		mouseX_old = mouseX;
		mouseY_old = mouseY;
		System.out.println(System.getProperty("user.dir"));
	}

	public void draw() {

		background(0x00FFFFFF);
		ps.run(this);
		
		for (int i = 0; i < 1; i++) {	
			ps.addParticle(mouseX,mouseY);	
		}
		
//		ellipse(50, 50, 50, 50);
//		newImg = fastblur( this.get() );
//		image(newImg, 0, 0);
		
//		filter(BLUR, 2.0F);
		
//		newImg = loadImage("ellipse_blur.png");
//		image(newImg, 30, 30);
		
//		text(frameRate, 10, 10);

	}
	
	PImage fastblur(PImage img) {
		
		for (int x = 1; x < height-1; x++) {
			for (int y = 1; y < width-1; y++) {
				int newVal_g = img.get(x-1, y-1)&0xFF + img.get(x-1, y)&0xFF + img.get(x-1, y+1)&0xFF
						+ img.get(x, y-1)&0xFF + img.get(x, y)&0xFF + img.get(x, y+1)&0xFF
						+ img.get(x+1, y-1)&0xFF + img.get(x+1, y)&0xFF + img.get(x+1, y+1)&0xFF;
				newVal_g = newVal_g/9;
				img.set(x, y, newVal_g);
				
			}			
		}
		return img;
	}

}
